function objectToQueryString(params) {
  return Object.keys(params)
    .filter(key => params[key] !== undefined) // 过滤掉值为undefined的键值对
    .map(
      (key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`
    )
    .join('&');
}

export default objectToQueryString;
